package com.itheima.app.config;

import lombok.Data;

@Data
public class R<T>{
    private boolean flag;
    private String message;
    private Object data;

    public static R success(Object data) {
        R r = new R();
        r.flag = true;
        r.message = "OK";
        r.data = data;
        return r;
    }

    //TODO 自行添加其他操作成功或失败的静态方法

    /**
     * 失败
     */
    public static R error(String message) {
        R r = new R();
        r.flag = false;
        r.message = message;
        return r;
    }

    /**
     * 成功
     */
    public static R success() {
        R r = new R();
        r.flag = true;
        r.message = "OK";
        return r;
    }
}